﻿@using HCMS.Extensions
@using Newtonsoft.Json
@model List<HCMS.Entities.Manage.Menu>

@* 单元格超过2个权限功能，使用 更多 展示 *@
@if (Model != null && Model.Count > 0)
{
    if (Model.Count <= 2)
    {
        <div class="layui-clear-space">
            @foreach (var item in Model)
            {
                <a class="layui-btn layui-btn-xs" lay-event="@item.ActionName.InitialSmall()" lay-on="@item.ActionName.InitialSmall()">
                    @item.DisplayName
                </a>
            }
        </div>
    }
    else
    {
        var dropdownDataList = Model.Skip(1).Select(t => new { title = t.DisplayName, id = t.ActionName.InitialSmall() }).ToList();

        <text>
            <div class="layui-clear-space">
                <a class="layui-btn layui-btn-xs" lay-event="@Model[0].ActionName.InitialSmall()" lay-on="@Model[0].ActionName.InitialSmall()">
                    @Model[0].DisplayName
                </a>
                <a class="layui-btn layui-btn-xs" lay-event="more" data-dropdown="@JsonConvert.SerializeObject(dropdownDataList)">
                    更多
                    <i class="layui-icon layui-icon-down"></i>
                </a>
            </div>
        </text>
    }
}